/*-------------------------------------------------------------------------

***************** Modification History ***********************************
   @doc
   @module pbatch.h - prototypes for batch functions |
   @end

$Log: /SoftPay/SPK2SIM/Source/Include/pbatch.h $
**************************************************************************

   Copyright (C) 1999 by VeriFone, Inc.

   All rights reserved.  No part of this software may be reproduced,
   transmitted, transcribed, stored in a retrieval system, or translated
   into any language or computer language, in any form or by any means,
   electronic, mechanical, magnetic, optical, chemical, manual or otherwise,
   without the prior written permission of VeriFone, Inc.

---------------------------------------------------------------------------*/
#ifndef PBATCH_H
#ifndef INTRAN_H
#define PBATCH_H

int inAddBatchFunctions(void);
int inCloseBatch (DB_FILE *psrDBFPtr);
int inClearBatch (TRANSACTION_OBJECT *pobTran, int inClearType, VS_BOOL fDisplayFlag);
int inClrBatch (TRANSACTION_OBJECT *pobTran, int inClearType, VS_BOOL fDisplayFlag);
int inGetKeyBatchRec (TRANSACTION_OBJECT *pobTran, int inKey, BATCH_KEY *psrBatchKey, long lnDBWhat, DB_FILE *psrDBF);
int inGetHostTranCnt (TRANSACTION_OBJECT *pobTran);
int inGetOBatchRecCnt (TRANSACTION_OBJECT *pobTran);
int inLoadBatchRec (TRANSACTION_OBJECT *pobTran, int inRecNum);
int inLoadNextBatchRec (TRANSACTION_OBJECT *pobTran, long lnDBWhat);
int inLoadOBatchRec (TRANSACTION_OBJECT *pobTran, int inRecNum);
int inPutPreAuthBatRec (TRANSACTION_OBJECT *pobTran);
VS_BOOL fReversalsEmpty(void);
void vdBatchOTOpen (TRANSACTION_OBJECT *pobTran);
void vdBatchDCOpen (TRANSACTION_OBJECT *pobTran);
void vdCloseTabBatch(TRANSACTION_OBJECT *pobTran);
void vdCloseDCBatch(TRANSACTION_OBJECT *pobTran);
void vdUndoAdjustBatchRec (TRANSACTION_OBJECT *pobTran);
void vdUndoVoidBatchRec (TRANSACTION_OBJECT *pobTran);
int inAnyIndependentBatches (void);
VS_BOOL fIsIndependentBatch (int inHostNum );
int inCompareFn (BATCH_KEY *psrBKey, BATCH_SKEY *Matchstr);
int inUpdateBatchFlow (TRANSACTION_OBJECT *pobTran);
int inCheckForDuplicate(TRANSACTION_OBJECT *pobTran);
int inDeleteOpenTab(TRANSACTION_OBJECT *pobTran);
int inOpenTabBatch(TRANSACTION_OBJECT *pobTran);
int inOpenDCBatch(TRANSACTION_OBJECT *pobTran);
int inUpdateBatch (TRANSACTION_OBJECT *pobTran);
int inCheckOpenTabs (TRANSACTION_OBJECT *pobTran);
int inSettleUnadjTipsFunction (TRANSACTION_OBJECT *pobTran);
int inSettleUnadjustTips(TRANSACTION_OBJECT *pobTran);
int inGetInvBatchRec(TRANSACTION_OBJECT *pobTran, int inKey, long lnDBWhat, DB_FILE *psrDBF);
int inVoidBatchRec (TRANSACTION_OBJECT *pobTran);
int inPurgeHostFromBatch(TRANSACTION_OBJECT *pobTran, int inHostNum, VS_BOOL fDisplayFlag);
int inAdjustBatchRec (TRANSACTION_OBJECT *pobTran);
int inSettleOpenTabs (TRANSACTION_OBJECT *pobTran);
int inBatchClearOperation (TRANSACTION_OBJECT *pobTran);
int inInitPurgeHostFromBatch(TRANSACTION_OBJECT *pobTran);
int inInitBatchStructures(BATCH_KEY *psrBKey, BATCH_REC *psrBRec);
int inWriteBatchData (DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum);
int inOldWriteBatchData (DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum);
int inReadBatchData (DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum);
int inOldReadBatchData (DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum);
int inReadReprintBatchData (DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum);
int inGetLocalBatchStructures(BATCH_KEY **psrBKey, BATCH_REC **psrBRec);
void vdFreeLocalBatchStructures(BATCH_KEY *psrBKey, BATCH_REC *psrBRec);
long lnBatchGetKey(DB_FILE *psrDBF, BATCH_KEY *psrBKey, BATCH_SKEY *psrBSKey, long lnDBWhat, BATCH_REC *psrBRec, long *plnRecNum);
int inStoreBatchFieldData(BATCH_REC *psrBRec, unsigned int uiFieldID, unsigned char * pchData, unsigned short shDataLength);
int inGetBatchFieldData(BATCH_REC *psrBRec, unsigned int uiFieldID, unsigned char * pchData, unsigned short shMaxLength);

int inImamModifyCurrentBatchRec(TRANSACTION_OBJECT* pobTran); //
int inUpdateBatchForVoid(TRANSACTION_OBJECT *pobTran);
int inUpdateBatchForAdjust(TRANSACTION_OBJECT *pobTran);
int inUpdateBatchForVoidAndAdjust(TRANSACTION_OBJECT *pobTran);
int	inDefaultUpdateBatchForVoid(TRANSACTION_OBJECT *pobTran);
int	inDefaultUpdateBatchForAdjust(TRANSACTION_OBJECT *pobTran);
int	inDefaultUpdateBatchForVoidAndAdjust(TRANSACTION_OBJECT *pobTran);
int	inDefaultIsVoidTransaction (TRANSACTION_OBJECT *pobTran);
int inGetOTKeyBatchRec (TRANSACTION_OBJECT *pobTran, int inKey, BATCH_KEY *psrBatchKey, long lnDBWhat);
int inGetDCKeyBatchRec (TRANSACTION_OBJECT *pobTran, int inKey, BATCH_KEY *psrBatchKey, long lnDBWhat);
int inGetDCInvBatchRec (TRANSACTION_OBJECT *pobTran, int inKey, long lnDBWhat);
int inGetLinkedKeyBatchRec(TRANSACTION_OBJECT *pobTran, int inKey, BATCH_KEY *psrBatchKey, long lnDBWhat, DB_FILE *psrDBF);
int inGetOTInvBatchRec (TRANSACTION_OBJECT *pobTran, int inKey, long lnDBWhat);


int BATCH_CODE_CHECK(char * a,char *b,short *  c,char * d,unsigned char * e);
int BATCHFUN_CODE_CHECK(char * a,char *b,short *  c,char * d,unsigned char * e);
int BATCHTAB_CODE_CHECK(char * a,char *b,short *  c,char * d,unsigned char * e);
int BATCHFLX_CODE_CHECK(char * a,char *b,short *  c,char * d,unsigned char * e);

void vdGetBatchFName (char *pchBFName);
void vdResetMaxBatchRecSize (void);
void vdReversalsDelete(int inHostNum);

int inLoadCardCurrenyHostData (TRANSACTION_OBJECT *pobTran);
int inLoadDCBatchRec (TRANSACTION_OBJECT *pobTran, int inRecNum);
int inCloseDCBatch(TRANSACTION_OBJECT *pobTran);
int inCloseTabBatch(TRANSACTION_OBJECT *pobTran);

void vdGetOpenTabBatchFName (char *pchBFName);
static int inCheckUnadjustTips(TRANSACTION_OBJECT *pobTran);
int inDeleteOBatchRec (TRANSACTION_OBJECT *pobTran);
//static int inAddBatchRec ( TRANSACTION_OBJECT *pobTran, BATCH_KEY *psrBKey, BATCH_REC *psrBRec, long lnRecNum );
int inPutBatchRec (TRANSACTION_OBJECT *pobTran);
int inGetBatchRec (TRANSACTION_OBJECT *pobTran, int inRecNum);
//static int inGetOBatchRec (TRANSACTION_OBJECT *pobTran, int inRecNum);
int inOpenBatch (DB_FILE *psrDBFPtr, char *pchFName);
static int inGetBatchDataInfo (char * pchData);
static int inSetBatchDataInfo (char * pchData);
static int inGetMaxBatchRecSize (void);
static int inSetMaxBatchRecSize (int inRecSize);
static int inLoadCDTandCST (TRANSACTION_OBJECT *pobTran);

void vdGetDupChkFName (char *pchFName);
int inDeleteOpenTabBatch (TRANSACTION_OBJECT *pobTran);
int inDeleteAllBatches (TRANSACTION_OBJECT *pobTran);

int inStoreOptionalBatchRecToFlexi ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inStoreRoomNum ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inStoreCustNum ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inStoreT1Data ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inStoreT2Data ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inStoreCHolder ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );

int inLoadOptionalBatchRecFromFlexi ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inLoadRoomNum ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inLoadCustNum ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inLoadT1Data ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inLoadT2Data ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );
int inLoadCHolder ( unsigned char *pchTempMaxBatchRecFlexi, BATCH_REC *psrBRec );

#endif
#endif
